﻿(function ($) {
    app.modals.CreateOrEditAlcCodeDetailModal = function () {
        var _modalManager;

        var _alcCodeDetailService = abp.services.app.alcCodeDetail;

        //$(".maxlength-handler").maxlength({
        //    limitReachedClass: "label label-danger",
        //    alwaysShow: true,
        //    threshold: 5,
        //    placement: 'bottom'
        //});

        var _$alcCodeDetailInformationForm = null;

        this.init = function (modalManager) {
            _modalManager = modalManager;
            _$alcCodeDetailInformationForm = _modalManager.getModal().find("form[name=alcCodeDetailInformationsForm]");

            //渲染select
            $("#alcCodeIdEdit").selectpicker();

            //渲染select
            $("#seatPositionIdEdit").selectpicker();

            //渲染select
            $("#materialIdEdit").selectpicker();

            //渲染select
            $("#slideEdit").selectpicker();

            //渲染select
            $("#hGITEdit").selectpicker();

            //渲染select
            $("#lumbarSupportEdit").selectpicker();

            //渲染select
            $("#warmerEdit").selectpicker();

            //渲染select
            $("#ventlationEdit").selectpicker();

            //渲染select
            $("#sABEdit").selectpicker();

            //渲染select
            $("#backPocketEdit").selectpicker();

            //渲染select
            $("#sBREdit").selectpicker();

            //渲染select
            $("#iMSEdit").selectpicker();

            //渲染select
            $("#oneTouchEdit").selectpicker();
        }

        this.save = function () {
            if (!_$alcCodeDetailInformationForm.valid()) {
                return;
            }
            //校验通过

            var alcCodeDetail = _$alcCodeDetailInformationForm.serializeFormToObject();
            //  console.log(alcCodeDetail);

            _modalManager.setBusy(true);

            _alcCodeDetailService.createOrUpdateAlcCodeDetailAsync({
                alcCodeDetailEditDto: alcCodeDetail
            }).done(function () {
                //提示信息
                abp.notify.info(app.localize('SavedSuccessfully'));
                //关闭窗体
                _modalManager.close();
                //信息保存成功后调用事件，刷新列表
                abp.event.trigger('app.createOrEditAlcCodeDetailModalSaved');
            }).always(function () {
                _modalManager.setBusy(false);
            });
        }
    }
})(jQuery);